package cn.com.guage.flink.transformation;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 
 * @author yangdechao filter算子用法
 *
 */
public class FilterTransformation {

	public static void main(String[] args) throws Exception {
		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		DataStreamSource<String> textStream = env.readTextFile("data/map-data.txt");
		//textStream.print();

		SingleOutputStreamOperator<String> resuilt = textStream.filter(new MyFilter());
		resuilt.print();
		env.execute();
	}

	public static final class MyFilter implements FilterFunction<String> {

		/**
		 * 
		 */
		private static final long serialVersionUID = -292987614739096092L;

		public boolean filter(String value) throws Exception {
			
			String name = value.split(",")[0];
			return "杨得朝".equals(name);
		}
		

	}
}
